//
//  GameDetailTextCell.swift
//  XiaoJingMallSwift
//
//  Created by beisheng03 on 2017/8/5.
//  Copyright © 2017年 beisheng. All rights reserved.
//

import UIKit

class GameDetailTextCell: BaseTableViewCell {
    
    @IBOutlet weak var bottomMargin: NSLayoutConstraint!
    
    @IBOutlet weak var topLabel: UILabel!
    var textStr = "-999"{
        
        
        didSet{
            
            let temp = textStr.characters.count > 0 ? textStr : "暂无"
            
            topLabel.attributedText = attributedString(str: temp, font: UIFont.systemFont(ofSize: 15))
            
        }
        
    }

    override func awakeFromNib() {
        super.awakeFromNib()
        contentView.backgroundColor = UIColor.white
        
        bottomMargin.constant = 0
        
        topLabel.textColor = UIColor.dakGray()
        
        topLabel.font = UIFont.systemFont(ofSize: 15)
        // Initialization code
    }
    
    
    func attributedString(str: String, font: UIFont) -> NSAttributedString? {
        
        
        if str.characters.count > 0 {
            
        
        // 根据原有字符串生成属性字符串
        let strM = NSMutableAttributedString(string: str)
        
        strM.addAttribute(NSFontAttributeName, value: font, range:NSMakeRange(0, str.characters.count))
        
        strM.addAttribute(NSForegroundColorAttributeName, value: UIColor.dakGray(), range:NSMakeRange(0, str.characters.count) )
        
        
        let paragr = NSMutableParagraphStyle.init()
        
        paragr.firstLineHeadIndent = 20;
        
        paragr.lineSpacing = 8;
        
        paragr.paragraphSpacing = 2
        
        strM.addAttribute(NSParagraphStyleAttributeName, value: paragr, range: NSMakeRange(0, str.characters.count))
        
        
        
        return strM
        
        
       }
        
        return nil
        
    }
    
    
    
    

    

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
    
}
